package tree;

public class HuffManTreeNode<T> implements Comparable<HuffManTreeNode<T>> {
    private Integer value;
    private T element;
    private HuffManTreeNode<T> left;
    private HuffManTreeNode<T> right;

    private boolean leftPre;
    private boolean rightPost;
    public HuffManTreeNode() {
    }

    public boolean isLeftPre() {
        return leftPre;
    }

    public void setLeftPre(boolean leftPre) {
        this.leftPre = leftPre;
    }

    public boolean isRightPost() {
        return rightPost;
    }

    public void setRightPost(boolean rightPost) {
        this.rightPost = rightPost;
    }

    public HuffManTreeNode(Integer value, T element) {
        this.value = value;
        this.element = element;
        this.left = null;
        this.right = null;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public T getElement() {
        return element;
    }

    public void setElement(T element) {
        this.element = element;
    }

    public HuffManTreeNode<T> getLeft() {
        return left;
    }

    public void setLeft(HuffManTreeNode<T> left) {
        this.left = left;
    }

    public HuffManTreeNode<T> getRight() {
        return right;
    }

    public void setRight(HuffManTreeNode<T> right) {
        this.right = right;
    }

    public void preOrderPrint(){
        printNode();
        if(left!=null){
            left.preOrderPrint();
        }
        if(right!=null){
            right.preOrderPrint();
        }
    }
    public void printNode(){
        System.out.println("value:"+value+",element:"+element);
    }

    @Override
    public int compareTo(HuffManTreeNode<T> o) {
        return value.compareTo(o.getValue());
    }
}
